#ifndef __LUNA_VorbisSound_h__
#define __LUNA_VorbisSound_h__

#include "LUNA_Common.h"
#include "LUNA_ISound.h"

#include "al.h"
#include "Vorbis\vorbisfile.h"

#define NUMBUFFERS 4

namespace LUNA
{
	class LunaExport VorbisSound : public ISound
	{
	public:
		VorbisSound( const std::string &filename, VorbisSystem &vorbisSystem );
		virtual ~VorbisSound();
		
		virtual void update();
		
		void setPlayState( SoundPlayState state );
		SoundPlayState getPlayState() const;
		
		virtual void setVolume( float volume );
		virtual void _setMasterVolume( float volume );

	private:
		VorbisSystem &mVorbisSystem;
		OggVorbis_File mOggVorbisFile;

		unsigned long mFrequency;
		unsigned long mFormat;
		unsigned long mChannels;
		unsigned long mBufferSize;
		unsigned long mBytesWritten;
		char *mDecodeBuffer;

		ALuint mBuffers[NUMBUFFERS];
		ALuint mSource;
		ALuint mBuffer;
		ALint mState;
		ALint mLoop;
		ALint mBuffersProcessed;
		ALint mTotalBuffersProcessed;
		ALint mQueuedBuffers;
	};
}

#endif